//*****************************************************************************
//* Foxit Digital Rights Management Library
//*
//* Foxit Software Inc.
//* Copyright(C) 2005-2010, all rights reserved.
//*
//* The following code is copyrighted and contains proprietary information
//* and trade secrets of Foxit Software Inc.
//*****************************************************************************
/**
 * @addtogroup FDRM
 * @{
 */

/**
 * @file
 * @brief Define interfaces, classes & functions for descriptions.
 */

#ifndef _FDRM_DESC
#define _FDRM_DESC

//Classes defined in this header
class IFDRM_CategoryRead;
	class IFDRM_CategoryWrite;
class IFDRM_DescRead;
	class IFDRM_DescWrite;
class IFDRM_ContentsRead;
	class IFDRM_ContentsWrite;
class IFDRM_TOCRead;
	class IFDRM_TOCWrite;
class IFDRM_ResourceRead;
	class IFDRM_ResourceWrite;
class IFDRM_PermissionRead;
	class IFDRM_PermissionWrite;
class IFDRM_EncryptionRead;
	class IFDRM_EncryptionWrite;
class IFDRM_FoacRead;
	class IFDRM_FoacWrite;

//*****************************************************************************
//* Category
//*****************************************************************************
FX_DEFINEHANDLE(FDRM_HCATEGORY);

class IFDRM_CategoryRead : public CFDRM_Object
{
public:
	virtual FX_INT32		CountSubCategories(FDRM_HCATEGORY hParent, FX_BSTR bsFilter) const = 0;
	virtual FDRM_HCATEGORY	GetSubCategory(FDRM_HCATEGORY hParent, FX_BSTR bsFilter, FX_INT32 index) const = 0;
	virtual FDRM_HCATEGORY	FindSubCategory(FDRM_HCATEGORY hParent, FX_BSTR bsFilter, FX_BSTR bsKey, FX_BSTR bsValue, FX_LPVOID pCur = NULL) const = 0;
	virtual FDRM_HCATEGORY	GetParentCategory(FDRM_HCATEGORY hCategory) const = 0;

	virtual FX_INT32		GetCategoryName(FDRM_HCATEGORY hCategory, CFX_ByteString &bsCategory) const = 0;
	virtual FX_INT32		CountAttributes(FDRM_HCATEGORY hCategory) const = 0;
	virtual FX_INT32		GetAttribute(FDRM_HCATEGORY hCategory, FX_INT32 index, CFX_ByteString &bsName, CFX_ByteString &bsValue) const = 0;
	virtual FX_INT32		GetAttributeValue(FDRM_HCATEGORY hCategory, FX_BSTR bsName, CFX_ByteString &bsValue) const = 0;

	virtual FX_INT32		GetCategoryData(FDRM_HCATEGORY hCategory, CFX_ByteString &bsData) const = 0;
	virtual FX_INT32		GetCategoryData(FDRM_HCATEGORY hCategory, CFDRM_ByteKeyString &bksData) const = 0;
};

class IFDRM_CategoryWrite : public IFDRM_CategoryRead
{
public:
	virtual FDRM_HCATEGORY	AddCategory(FDRM_HCATEGORY hParent, FX_BSTR bsCategory, FX_BOOL bUnique = FALSE) = 0;
	virtual FDRM_HCATEGORY	AddCategory(FDRM_HCATEGORY hParent, FX_BSTR bsCategory, FX_BSTR bsKey, FX_BSTR bsValue) = 0;

	virtual void			SetAttribute(FDRM_HCATEGORY hCategory, FX_BSTR bsName, FX_BSTR bsValue) = 0;
	virtual void			RemoveAttribute(FDRM_HCATEGORY hCategory, FX_BSTR bsName) = 0;
	virtual void			SetCategoryData(FDRM_HCATEGORY hCategory, FX_BSTR bsData) = 0;
	virtual void			SetCategoryData(FDRM_HCATEGORY hCategory, const CFDRM_ByteKeyString &bsData) = 0;
	virtual void			RemoveCategory(FDRM_HCATEGORY hParent, FX_BSTR bsCategory) = 0;
	virtual void			RemoveCategory(FDRM_HCATEGORY hParent, FDRM_HCATEGORY hCategory) = 0;
	virtual void			RemoveCategory(FDRM_HCATEGORY hCategory) = 0;
};

//*****************************************************************************
//* Descriptor
//*****************************************************************************
/**
 * @name Descriptor - basic descriptor for all materials
 */
/*@{*/

#define FDRM_DESCTYPE_Contents		FX_BSTR("Contents")
#define FDRM_DESCTYPE_TOC			FX_BSTR("TOC")
#define FDRM_DESCTYPE_Resource		FX_BSTR("Resource")
#define FDRM_DESCTYPE_Permission	FX_BSTR("Permission")
#define FDRM_DESCTYPE_Encryption	FX_BSTR("Encryption")
#define FDRM_DESCTYPE_Certificate	FX_BSTR("Certificate")
#define FDRM_DESCTYPE_Envelope		FX_BSTR("Envelope")
#define FDRM_DESCTYPE_Foac			FX_BSTR("Foac")

FX_DEFINEHANDLE(FDRM_HDESCSCRIPT);
FX_DEFINEHANDLE(FDRM_HDESCPRES);
FX_DEFINEHANDLE(FDRM_HDESCSIGN);

class CFDRM_DescData : public CFDRM_Object
{
public:
	CFX_ByteString		m_bsPackage;
	CFX_ByteString		m_bsDefNamespace;
	CFX_ByteString		m_bsFDRMNamespace;
};

class CFDRM_ScriptData : public CFDRM_Object
{
public:
	CFX_ByteString		m_bsDivision;
	CFX_ByteString		m_bsFormatOrg;
	CFX_ByteString		m_bsFormatVer;
	CFX_ByteString		m_bsApplicationOrg;
	CFX_ByteString		m_bsApplicationVer;
	CFX_ByteString		m_bsAuthority;
};

class CFDRM_PresentationData : public CFDRM_Object
{
public:
	CFX_ByteString		m_bsDivision;
	CFX_ByteString		m_bsAuthority;
};

class CFDRM_SignatureData : public CFDRM_Object
{
public:
	CFX_ByteString			m_bsDivision;
	CFX_ByteString			m_bsAgentOrg;
	CFX_ByteString			m_bsAgentVer;
	CFX_ByteString			m_bsFormatOrg;
	CFX_ByteString			m_bsFormatVer;
	CFDRM_ByteKeyString		m_bsKey;
};

class IFDRM_DescRead : public CFDRM_Object
{
public:
	virtual FX_INT32				Load(IFX_FileRead *pFile) = 0;

	virtual FX_INT32				VerifyDescriptor(const CFDRM_DescData &descData) const = 0;
	virtual void					GetDescType(CFX_ByteString &bsType) const = 0;

	virtual FDRM_HDESCSCRIPT		GetScript(const CFDRM_ScriptData &scriptData) const = 0;
	virtual FX_INT32				CountScripts() const = 0;
	virtual FDRM_HDESCSCRIPT		GetScript(FX_INT32 nIndex) const = 0;
	virtual FX_INT32				GetScriptData(FDRM_HDESCSCRIPT hScript, CFDRM_ScriptData &scriptData) const = 0;
	virtual IFDRM_CategoryRead*		GetScriptParams(FDRM_HDESCSCRIPT hScript) const = 0;

	virtual FDRM_HDESCPRES			GetPresentation(FDRM_HDESCSCRIPT hScript, const CFDRM_PresentationData &presData) const = 0;
	virtual FX_INT32				GetPresentationData(FDRM_HDESCPRES hPresentation, CFDRM_PresentationData &presData) const = 0;
	virtual IFDRM_CategoryRead*		GetPresentationParams(FDRM_HDESCPRES hPresentation) const = 0;

	virtual FDRM_HDESCSIGN			GetSignature(const CFDRM_SignatureData &signData) const = 0;
	virtual FX_INT32				GetSignatureData(FDRM_HDESCSIGN hSign, CFDRM_SignatureData &signData) const = 0;
	virtual IFDRM_CategoryRead*		GetSignatureParams(FDRM_HDESCSIGN hSign) const = 0;
	virtual FX_INT32				GetSignatureData(FDRM_HDESCSIGN hSign, CFDRM_ByteKeyString &bksData) const = 0;
	virtual FX_INT32				CheckSignature(FDRM_HDESCSIGN hSign, const CFDRM_ByteKeyString &bksKey) const = 0;

	virtual FX_INT32				VerifyValidation() const = 0;
};

IFDRM_DescRead*		FDRM_DescRead_Create();

class IFDRM_DescWrite : public IFDRM_DescRead
{
public:
	virtual FX_INT32				InitDescriptor(const CFDRM_DescData &descData) = 0;

	virtual void					RemoveScript(FX_BSTR bsDivision) = 0;
	virtual FDRM_HDESCSCRIPT		AddScript(const CFDRM_ScriptData &scriptData) = 0;
	virtual FX_INT32				SetScriptFormat(FDRM_HDESCSCRIPT hScript, FX_BSTR bsOrg, FX_BSTR bsVer) = 0;
	virtual FX_INT32				SetScriptApplication(FDRM_HDESCSCRIPT hScript, FX_BSTR bsOrg, FX_BSTR bsVer) = 0;
	virtual FX_INT32				SetScriptAuthority(FDRM_HDESCSCRIPT hScript, FX_BSTR bsAuth) = 0;
	virtual IFDRM_CategoryWrite*	SetScriptParams(FDRM_HDESCSCRIPT hScript) = 0;

	virtual void					RemovePresentation(FDRM_HDESCSCRIPT hScript, FX_BSTR bsDivision) = 0;
	virtual FDRM_HDESCPRES			AddPresentation(FDRM_HDESCSCRIPT hScript, const CFDRM_PresentationData &presData) = 0;
	virtual FX_INT32				SetPresentationAuthority(FDRM_HDESCPRES hPresentation, FX_BSTR bsAuth) = 0;
	virtual IFDRM_CategoryWrite*	SetPresentationParams(FDRM_HDESCPRES hPresentation) = 0;

	virtual void					RemoveSignature(FX_BSTR bsDivision) = 0;
	virtual FDRM_HDESCSIGN			AddSignature(const CFDRM_SignatureData &signData) = 0;
	virtual FX_INT32				SetSignatureAgent(FDRM_HDESCSIGN hSign, FX_BSTR bsOrg, FX_BSTR bsVer) = 0;
	virtual FX_INT32				SetSignatureFormat(FDRM_HDESCSIGN hSign, FX_BSTR bsOrg, FX_BSTR bsVer) = 0;
	virtual IFDRM_CategoryWrite*	SetSignatureParams(FDRM_HDESCSIGN hSign) = 0;
	virtual FX_INT32				SetSignatureKey(FDRM_HDESCSIGN hSign, const CFDRM_ByteKeyString &bksKey) = 0;

	virtual FX_BOOL					Save(IFX_FileWrite *pFile) = 0;
};

IFDRM_DescWrite*	FDRM_DescWrite_Create(FX_BSTR bsType);

/*@}*/

//*****************************************************************************
//* Contents
//*****************************************************************************
/**
 * @name Contents - abstract and some basic descriptions
 */
/*@{*/

FX_DEFINEHANDLE(FDRM_HCONTENTS);

class IFDRM_ContentsRead : public CFDRM_Object
{
public:
	virtual IFDRM_DescRead*		GetDescRead() const = 0;
	virtual FX_INT32			VerifyContents(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FX_INT32			CountContents() const = 0;
	virtual FDRM_HCONTENTS		GetContents(FX_INT32 nIndex) const = 0;
	virtual FDRM_HCONTENTS		GetContents(FX_BSTR bsType) const = 0;

	virtual FX_INT32			GetContentsType(FDRM_HCONTENTS hContents, CFX_ByteString &bsType) const = 0;
	virtual FX_INT32			GetContentsText(FDRM_HCONTENTS hContents, CFX_ByteString &bsText) const = 0;
};

IFDRM_ContentsRead*		FDRM_ContentsRead_Create(IFDRM_DescRead *pDescRead = NULL);

class IFDRM_ContentsWrite : public IFDRM_ContentsRead
{
public:
	virtual IFDRM_DescWrite*	GetDescWrite() const = 0;
	virtual FX_INT32			InitContents(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FDRM_HCONTENTS		AddContents(FX_BSTR bsType) = 0;
	virtual FX_INT32			SetContentsText(FDRM_HCONTENTS hContents, FX_BSTR bsText) = 0;
	virtual void				RemoveContents(FDRM_HCONTENTS hContents) = 0;
	virtual void				RemoveAll() = 0;
};

IFDRM_ContentsWrite*	FDRM_ContentsWrite_Create(IFDRM_DescWrite *pDescWrite = NULL);

/*@}*/

//*****************************************************************************
//* TOC
//*****************************************************************************
/**
 * @name TOC - table of contents
 */
/*@{*/

FX_DEFINEHANDLE(FDRM_HTOC);

class IFDRM_TOCRead : public CFDRM_Object
{
public:
	virtual IFDRM_DescRead*		GetDescRead() const = 0;
	virtual FX_INT32			VerifyTOC(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FX_INT32			CountSubItems(FDRM_HTOC hParent) const = 0;
	virtual FDRM_HTOC			GetSubItem(FDRM_HTOC hParent, FX_INT32 nIndex) const = 0;
	virtual FDRM_HTOC			GetParentItem(FDRM_HTOC hToc) const = 0;
	virtual FX_INT32			GetTitle(FDRM_HTOC hToc, CFX_ByteString &bsTitle) const = 0;
	virtual FX_INT32			GetDescription(FDRM_HTOC hToc, CFX_ByteString &bsDesc) const = 0;
};

IFDRM_TOCRead*		FDRM_TOCRead_Create(IFDRM_DescRead *pDescRead = NULL);

class IFDRM_TOCWrite : public IFDRM_TOCRead
{
public:
	virtual IFDRM_DescWrite*	GetDescWrite() const = 0;
	virtual FX_INT32			InitTOC(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FDRM_HTOC			AddItem(FDRM_HTOC hParent, FX_BSTR bsTitle) = 0;
	virtual FX_INT32			SetDescription(FDRM_HTOC hToc, FX_BSTR bsDesc) = 0;
	virtual void				RemoveItem(FDRM_HTOC hToc) = 0;
	virtual void				RemoveAll() = 0;
};

IFDRM_TOCWrite*		FDRM_TOCWrite_Create(IFDRM_DescWrite *pDescWrite = NULL);

/*@}*/

//*****************************************************************************
//* Resource
//*****************************************************************************
/**
 * @name Resource - resources defined in DRM package
 */
/*@{*/

FX_DEFINEHANDLE(FDRM_HRESOURCE);

class IFDRM_ResourceRead : public CFDRM_Object
{
public:
	virtual IFDRM_DescRead*			GetDescRead() const = 0;
	virtual FX_INT32				VerifyResource(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FX_INT32				CountSubResources(FDRM_HRESOURCE hParent) const = 0;
	virtual FDRM_HRESOURCE			GetSubResource(FDRM_HRESOURCE hParent, FX_INT32 nIndex) const = 0;
	virtual FDRM_HRESOURCE			GetResource(FX_BSTR bsPathID) const = 0;
	virtual FDRM_HRESOURCE			GetParentResource(FDRM_HRESOURCE hResource) const = 0;

	virtual FX_INT32				GetResourceFormat(FDRM_HRESOURCE hResource, CFX_ByteString &bsFormat) const = 0;
	virtual FX_INT32				GetResourceNodeID(FDRM_HRESOURCE hResource, CFX_ByteString &bsNodeID) const = 0;
	virtual FX_INT32				GetResourcePathID(FDRM_HRESOURCE hResource, CFX_ByteString &bsPathID) const = 0;
	virtual IFDRM_CategoryRead*		GetResourceParams(FDRM_HRESOURCE hResource) const = 0;
};

IFDRM_ResourceRead*		FDRM_ResourceRead_Create(IFDRM_DescRead *pDescRead = NULL);

class IFDRM_ResourceWrite : public IFDRM_ResourceRead
{
public:
	virtual IFDRM_DescWrite*		GetDescWrite() const = 0;
	virtual FX_INT32				InitResource(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FDRM_HRESOURCE			AddResource(FDRM_HRESOURCE hParent, FX_BSTR bsFormat, FX_BSTR bsNodeID) = 0;
	virtual IFDRM_CategoryWrite*	SetResourceParams(FDRM_HRESOURCE hResource) = 0;
	virtual void					RemoveResource(FDRM_HRESOURCE hResource) = 0;
	virtual void					RemoveAll() = 0;
};

IFDRM_ResourceWrite*	FDRM_ResourceWrite_Create(IFDRM_DescWrite *pDescWrite = NULL);

/*@}*/

//*****************************************************************************
//* Permission
//*****************************************************************************
/**
 * @name Permission - authorization & rights
 */
/*@{*/

FX_DEFINEHANDLE(FDRM_HCONSUMER);
FX_DEFINEHANDLE(FDRM_HAUTHKEY);
FX_DEFINEHANDLE(FDRM_HCONDITION);
FX_DEFINEHANDLE(FDRM_HLIMIT);

class CFDRM_AuthKeyData : public CFDRM_Object
{
public:
	CFX_ByteString	m_bsID;
	CFX_ByteString	m_bsSource;
	CFX_ByteString	m_bsVerify;
	CFX_ByteString	m_bsTreatment;
	CFX_ByteString	m_bsVersion;
	CFX_ByteString	m_bsOrder;
	CFX_ByteString	m_bsValue;
};

class IFDRM_PermissionRead : public CFDRM_Object
{
public:
	virtual IFDRM_DescRead*			GetDescRead() const = 0;
	virtual FX_INT32				VerifyPermission(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FX_INT32				CountConsumers() const = 0;
	virtual FDRM_HCONSUMER			GetConsumer(FX_INT32 nIndex) const = 0;
	virtual FDRM_HCONSUMER			GetConsumer(FX_BSTR bsID) const = 0;
	virtual FX_INT32				CountMemebers(FDRM_HCONSUMER hConsumer) const = 0;
	virtual FX_INT32				GetMember(FDRM_HCONSUMER hConsumer, FX_INT32 nIndex, CFX_ByteString &bsID) const = 0;

	virtual FX_INT32				CountAuthKeys(FDRM_HCONSUMER hConsumer) const = 0;
	virtual FDRM_HAUTHKEY			GetAuthKey(FDRM_HCONSUMER hConsumer, FX_INT32 nIndex) const = 0;
	virtual FDRM_HAUTHKEY			GetAuthKey(FDRM_HCONSUMER hConsumer, FX_BSTR bsID) const = 0;
	virtual FX_INT32				GetAuthKey(FDRM_HAUTHKEY hAuthKey, CFDRM_AuthKeyData &akData) const = 0;

	virtual FX_BOOL					IsRole(FDRM_HCONSUMER hConsumer, FX_BSTR bsRole) const = 0;
	virtual FX_INT32				CountRoles(FDRM_HCONSUMER hConsumer) const = 0;
	virtual FX_INT32				GetRole(FDRM_HCONSUMER hConsumer, FX_INT32 nIndex, CFX_ByteString &bsRole) const = 0;

	virtual FX_INT32				CountConditions(FDRM_HCONSUMER hConsumer) const = 0;
	virtual FDRM_HCONDITION			GetCondition(FDRM_HCONSUMER hConsumer, FX_INT32 nIndex) const = 0;
	virtual FX_INT32				CountLimits(FDRM_HCONDITION hCondition) const = 0;
	virtual FDRM_HLIMIT				GetLimit(FDRM_HCONDITION hCondition, FX_INT32 nIndex) const = 0;
	virtual FX_INT32				GetLimitType(FDRM_HLIMIT hLimit, CFX_ByteString &bsType) const = 0;
	virtual FX_INT32				GetLimitData(FDRM_HLIMIT hLimit, CFX_ByteString &bsData) const = 0;
	virtual IFDRM_CategoryRead*		GetLimitParams(FDRM_HLIMIT hLimit) const = 0;
	virtual FX_INT32				CountResources(FDRM_HCONDITION hCondition) const = 0;
	virtual FX_INT32				GetResourceID(FDRM_HCONDITION hCondition, FX_INT32 nIndex, CFX_ByteString &bsResID) const = 0;
	virtual FX_INT32				CountResourceRights(FDRM_HCONDITION hCondition, FX_BSTR bsResID) const = 0;
	virtual FX_INT32				GetResourceRight(FDRM_HCONDITION hCondition, FX_BSTR bsResID, FX_INT32 nIndex, CFX_ByteString &bsRight) const = 0;
};

IFDRM_PermissionRead*	FDRM_PermissionRead_Create(IFDRM_DescRead *pDescRead = NULL);

class IFDRM_PermissionWrite : public IFDRM_PermissionRead
{
public:
	virtual IFDRM_DescWrite*		GetDescWrite() const = 0;
	virtual FX_INT32				InitPermission(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FDRM_HCONSUMER			AddConsumer(FX_BSTR bsID) = 0;
	virtual FX_INT32				AddMember(FDRM_HCONSUMER hConsumer, FX_BSTR bsMemberID) = 0;
	virtual void					RemoveMember(FDRM_HCONSUMER hConsumer, FX_BSTR bsMemberID) = 0;
	virtual void					RemoveConsumer(FDRM_HCONSUMER hConsumer) = 0;
	virtual void					RemoveAllConsumers() = 0;

	virtual FDRM_HAUTHKEY			AddAuthKey(FDRM_HCONSUMER hConsumer, const CFDRM_AuthKeyData &akData) = 0;
	virtual void					RemoveAuthKey(FDRM_HAUTHKEY hAuthKey) = 0;
	virtual void					RemoveAllAuthKeys(FDRM_HCONSUMER hConsumer) = 0;

	virtual FX_INT32				AddRole(FDRM_HCONSUMER hConsumer, FX_BSTR bsRole) = 0;
	virtual void					RemoveRole(FDRM_HCONSUMER hConsumer, FX_BSTR bsRole) = 0;
	virtual void					RemoveAllRoles(FDRM_HCONSUMER hConsumer) = 0;

	virtual FDRM_HCONDITION			AddCondition(FDRM_HCONSUMER hConsumer) = 0;
	virtual void					RemoveCondition(FDRM_HCONDITION hCondition) = 0;
	virtual void					RemoveAllConditions(FDRM_HCONSUMER hConsumer) = 0;
	virtual FDRM_HLIMIT				AddLimit(FDRM_HCONDITION hCondition, FX_BSTR bsType) = 0;
	virtual FX_INT32				SetLimitData(FDRM_HLIMIT hLimit, FX_BSTR bsData) = 0;
	virtual IFDRM_CategoryWrite*	SetParams(FDRM_HLIMIT hLimit) = 0;
	virtual void					RemoveLimit(FDRM_HLIMIT hLimit) = 0;
	virtual void					RemoveAllLimits(FDRM_HCONDITION hCondition) = 0;
	virtual FX_INT32				AddResource(FDRM_HCONDITION hCondition, FX_BSTR bsResID) = 0;
	virtual void					RemoveResource(FDRM_HCONDITION hCondition, FX_BSTR bsResID) = 0;
	virtual void					RemoveAllResources(FDRM_HCONDITION hCondition) = 0;
	virtual FX_INT32				AddResourceRight(FDRM_HCONDITION hCondition, FX_BSTR bsResID, FX_BSTR bsRight) = 0;
	virtual void					RemoveResourceRight(FDRM_HCONDITION hCondition, FX_BSTR bsResID, FX_BSTR bsRight) = 0;
	virtual void					RemoveAllResourceRights(FDRM_HCONDITION hCondition, FX_BSTR bsResID) = 0;
};

IFDRM_PermissionWrite*	FDRM_PermissionWrite_Create(IFDRM_DescWrite *pDescWrite = NULL);

/*@}*/

//*****************************************************************************
//* Encryption
//*****************************************************************************
/**
 * @name Encryption - encryption settings
 */
/*@{*/

FX_DEFINEHANDLE(FDRM_HCIPHER);
FX_DEFINEHANDLE(FDRM_HCIPHERKEY);

class IFDRM_EncryptionRead : public CFDRM_Object
{
public:
	virtual IFDRM_DescRead*		GetDescRead() const = 0;
	virtual FX_INT32			VerifyEncryption(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FX_INT32			CountCiphers() const = 0;
	virtual FDRM_HCIPHER		GetCipher(FX_INT32 nIndex) const = 0;
	virtual FDRM_HCIPHER		GetResourceCipher(FX_BSTR bsResID) const = 0;
	virtual FX_INT32			GetCipherAlgorithm(FDRM_HCIPHER hCipher, CFX_ByteString &bsAlgorithm) const = 0;
	virtual FX_INT32			GetCipherVersion(FDRM_HCIPHER hCipher, CFX_ByteString &bsVersion) const = 0;
	virtual FX_INT32			CountCipherParams(FDRM_HCIPHER hCipher) const = 0;
	virtual FX_INT32			GetCipherParamName(FDRM_HCIPHER hCipher, FX_INT32 nIndex, CFX_ByteString &bsName) const = 0;
	virtual FX_INT32			GetCipherParamData(FDRM_HCIPHER hCipher, FX_INT32 nIndex, CFX_ByteString &bsData) const = 0;

	virtual FX_INT32			CountCipherKeys(FDRM_HCIPHER hCipher) const = 0;
	virtual FDRM_HCIPHERKEY		GetCipherKey(FDRM_HCIPHER hCipher, FX_INT32 nIndex) const = 0;
	virtual FX_INT32			GetCipherKeyRef(FDRM_HCIPHERKEY hCipherKey, CFX_ByteString &bsRef) const = 0;
	virtual FX_INT32			GetCipherKeyConsumer(FDRM_HCIPHERKEY hCipherKey, CFX_ByteString &bsConsumer) const = 0;
	virtual FX_INT32			GetCipherKeyID(FDRM_HCIPHERKEY hCipherKey, CFX_ByteString &bsID) const = 0;
	virtual FX_INT32			GetCipherKeySource(FDRM_HCIPHERKEY hCipherKey, CFX_ByteString &bsSource) const = 0;
	virtual FX_INT32			GetCipherKeyAlgorithm(FDRM_HCIPHERKEY hCipherKey, CFX_ByteString &bsAlgorithm) const = 0;
	virtual FX_INT32			GetCipherKeyOrder(FDRM_HCIPHERKEY hCipherKey, CFX_ByteString &bsOrder) const = 0;
	virtual FX_INT32			GetCipherKeyVersion(FDRM_HCIPHERKEY hCipherKey, CFX_ByteString &bsVersion) const = 0;
	virtual FX_INT32			GetCipherKeyData(FDRM_HCIPHERKEY hCipherKey, CFX_ByteString &bsData) const = 0;

	virtual FX_INT32			CountCipherResources(FDRM_HCIPHER hCipher) const = 0;
	virtual FX_INT32			GetCipherResource(FDRM_HCIPHER hCipher, FX_INT32 nIndex, CFX_ByteString &bsResID) const = 0;
	virtual FX_BOOL				HasResource(FDRM_HCIPHER hCipher, FX_BSTR bsResID) const = 0;
};

IFDRM_EncryptionRead*	FDRM_EncryptionRead_Create(IFDRM_DescRead *pDescRead = NULL);

class IFDRM_EncryptionWrite : public IFDRM_EncryptionRead
{
public:
	virtual IFDRM_DescWrite*	GetDescWrite() const = 0;
	virtual FX_INT32			InitEncryption(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FDRM_HCIPHER		AddCipher(FX_BSTR bsAlgorithm) = 0;
	virtual FX_INT32			SetCipherVersion(FDRM_HCIPHER hCipher, FX_BSTR bsVersion) = 0;
	virtual void				RemoveCipher(FDRM_HCIPHER hCipher) = 0;
	virtual void				RemoveAllCiphers() = 0;
	virtual FX_INT32			SetCipherParam(FDRM_HCIPHER hCipher, FX_BSTR bsName, FX_BSTR bsData) = 0;
	virtual void				RemoveCipherParam(FDRM_HCIPHER hCipher, FX_BSTR bsName) = 0;
	virtual void				RemoveAllCipherParams(FDRM_HCIPHER hCipher) = 0;

	virtual FDRM_HCIPHERKEY		AddCipherKey(FDRM_HCIPHER hCipher) = 0;
	virtual FX_INT32			SetCipherKeyRef(FDRM_HCIPHERKEY hCipherKey, FX_BSTR bsRef) = 0;
	virtual FX_INT32			SetCipherKeyConsumer(FDRM_HCIPHERKEY hCipherKey, FX_BSTR bsConsumer) = 0;
	virtual FX_INT32			SetCipherKeyID(FDRM_HCIPHERKEY hCipherKey, FX_BSTR bsID) = 0;
	virtual FX_INT32			SetCipherKeySource(FDRM_HCIPHERKEY hCipherKey, FX_BSTR bsSource) = 0;
	virtual FX_INT32			SetCipherKeyAlgorithm(FDRM_HCIPHERKEY hCipherKey, FX_BSTR bsAlgorithm) = 0;
	virtual FX_INT32			SetCipherKeyOrder(FDRM_HCIPHERKEY hCipherKey, FX_BSTR bsOrder) = 0;
	virtual FX_INT32			SetCipherKeyVersion(FDRM_HCIPHERKEY hCipherKey, FX_BSTR bsVersion) = 0;
	virtual FX_INT32			SetCipherKeyData(FDRM_HCIPHERKEY hCipherKey, FX_BSTR bsData) = 0;
	virtual void				RemoveCipherKey(FDRM_HCIPHERKEY hCipherKey) = 0;
	virtual void				RemoveAllCipherKeys(FDRM_HCIPHER hCipher) = 0;

	virtual FX_INT32			AddCipherResource(FDRM_HCIPHER hCipher, FX_BSTR bsResID) = 0;
	virtual void				RemoveCipherResource(FDRM_HCIPHER hCipher, FX_BSTR bsResID) = 0;
	virtual void				RemoveAllCipherResources(FDRM_HCIPHER hCipher) = 0;
};

IFDRM_EncryptionWrite*	FDRM_EncryptionWrite_Create(IFDRM_DescWrite *pDescWrite = NULL);

/*@}*/

//*****************************************************************************
//* Encryption
//*****************************************************************************
/**
 * @name Encryption - encryption settings
 */
/*@{*/

#define FDRM_FOACTYPE_Request	FX_BSTRC("FoxitFOACRequest")
#define FDRM_FOACTYPE_Answer	FX_BSTRC("FoxitFOACAnswer")

class IFDRM_FoacRead : public CFDRM_Object
{
public:
	virtual IFDRM_DescRead*			GetDescRead() const = 0;
	virtual FX_INT32				VerifyFoac(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FX_INT32				GetType(CFX_ByteString &bsType) const = 0;
	virtual FX_INT32				GetSessionID(CFX_ByteString &bsSessionID) const = 0;
	virtual FX_INT32				GetRequestID(CFX_ByteString &bsID) const = 0;
	virtual IFDRM_CategoryRead*		GetRequestData() const = 0;
	virtual FX_INT32				GetAnswerState(CFX_ByteString &bsState) const = 0;
	virtual IFDRM_CategoryRead*		GetAnswerData() const = 0;	
};

IFDRM_FoacRead*		FDRM_FoacRead_Create(IFDRM_DescRead *pDescRead = NULL);

class IFDRM_FoacWrite : public IFDRM_FoacRead
{
public:
	virtual IFDRM_DescWrite*		GetDescWrite() const = 0;
	virtual FX_INT32				InitFoac(const CFDRM_DescData &descData, const CFDRM_ScriptData &scriptData) = 0;

	virtual FX_INT32				SetSessionID(FX_BSTR bsSessionID) = 0;
	virtual FX_INT32				SetRequestID(FX_BSTR bsID) = 0;
	virtual IFDRM_CategoryWrite*	SetRequestData() = 0;
	virtual FX_INT32				SetAnswerState(FX_BSTR bsState) = 0;
	virtual IFDRM_CategoryWrite*	SetAnswerData() = 0;
};

IFDRM_FoacWrite*	FDRM_FoacWrite_Create(IFDRM_DescWrite *pDescWrite = NULL);

/*@}*/

#endif //_FDRM_DESC

/** @} */
